package com.opo5.logisticsmanagement.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.opo5.logisticsmanagement.domain.IndexCable;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author wangzhongwei
 */

@Mapper
public interface IndexPageDao extends BaseMapper<IndexCable> {

    @Select("select cablename,  sum(innum) as innum, sum(outnum) as outnum, sum(innum)-sum(outnum) as remaining" +
            " from tbs_cableplan where cablename like \"%铜%\" or cablename like \"%铝%\" group by cablename;")
    @Results({@Result(property="cablename",column="cablename")
            ,@Result(property="innum",column="innum")
            ,@Result(property="outnum",column="outnum")
            ,@Result(property="remaining",column="remaining")
    })
    List<IndexCable> getIndexInfo();
}
